<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" v-loading="formLoading" :rules="rules">
      <el-form-item label="标题：" style="margin-left:80px;margin-top:20px"  prop="title" required>
         <el-input v-model="queryParams.title"></el-input>
      </el-form-item>
      <el-form-item label="具体问题：" style="margin-left:80px;margin-top:20px " prop="detail" required>
        <Editor ref="editor" v-model="queryParams.detail" style="margin-top:40px;width: 60%;height: 100%" />
      </el-form-item> 
      <div class="button">
        <el-form-item>
          <el-button type="primary" @click="submitForm">提交</el-button>
          <el-button @click="resetForm" style="margin-left:50px">重置</el-button>
        </el-form-item>
      </div>

    </el-form>

    <!-- 添加或修改角色配置对话框 -->

    <!-- 分配角色数据权限对话框 -->
 
  </div>
</template>

<script>
import { create} from "@/api/question";
import Editor from '@/components/Editor';
export default {
  inject:['reload'],
   components: {
    Editor
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 角色表格数据
      roleList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 是否显示弹出层（数据权限）
      openDataScope: false,
      // 日期范围
      dateRange: [],
      // 状态数据字典
      statusOptions: [],
      // 数据范围选项
    
      // 菜单列表
      menuOptions: [],
      // 部门列表
      deptOptions: [],
      // 查询参数
      queryParams: {
        title:null,
        detail:null,
        pageIndex: 1,
        pageSize: 10
      },
      queryParam: {
        pageNum: 1,     
        pageSize: 10 
      },
      
      // 表单参数
      form: {},
      defaultProps: {
        children: "children",
        label: "label"
      },
      // 表单校验
      rules: {
        roleName: [
          { required: true, message: "角色名称不能为空", trigger: "blur" }
        ]
      }
    };
  },
  created() {
    
  },
  methods: {
    //提交工单
      submitForm () {
      let _this = this
      create(this.queryParams).then(data => {
            if (data.errno === 0) {
              _this.$message.success(data.errmsg)
              _this.$router.push('/upaper/history/index')
             
            } else {
              _this.$message.error(data.errmsg)
              
            }
          }).catch(e => {
            
          })
        } ,
    //页面数据重置
    resetForm () {
      this.reload()
    },
    /** 查询角色列表 */
    getList() {
      this.loading = true;
      getClassPageList(this.queryParams).then(
        response => {
         // console.log(response.response.list)
          this.roleList = response.response.list;
          this.total = response.response.total;
          this.loading = false;
        }
      );
    },
    // 角色状态修改
    handleStatusChange(row) {
      console.log(row.isEnabled)
      let text = row.isEnabled === 0? "停用" : "启用";
      console.log(text)
      this.$confirm('确认要"' + text + '""' + row.className + '"吗?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return changeStatus(row.id);
        }).then(() => {
          this.msgSuccess(text + "成功");
        }).catch(function() {
          row.isEnabled = row.isEnabled === 1 ? 0 : 1;
        });
    },
    
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
   
    /** 删除按钮操作 */
    handleDelete(row) {   
      console.log(row.id)
      deleteClass(row.id).then(re => {
        if (re.code === 1) {
         this.getList();
          this.$message.success(re.message)
        } else {
          this.$message.error(re.message)
        }
      })
    }
  }
};
</script>
<style rel="stylesheet/scss" lang="scss">
.button{
  margin-left: 90px;
  margin-top:80px;
}
</style>